﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tzx.Tools.Payroll2Images.Exe.TableToReport
{
    public partial class DemoFrm : Form
    {
        public DemoFrm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        protected DataTable table
        {
            get
            {
                if (_excelTable == null)
                {
                    _excelTable = new DemoData().CreateTable();

                    #region 添加2字段

                    //添加2字段
                    if (_excelTable != null)
                    {
                        //添加字段:表必需要有一个唯一行字段
                        if (!_excelTable.Columns.Contains(App.ColumnFixName_FID))
                        {
                            _excelTable.Columns.Add(App.ColumnFixName_FID, typeof(int));
                        }
                        //添加字段:表必需要有一个接收人名称字符串字段
                        if (!_excelTable.Columns.Contains(App.ColumnFixName_FEmployeeAllName))
                        {
                            _excelTable.Columns.Add(App.ColumnFixName_FEmployeeAllName, typeof(string));
                        }

                        int rowcount = _excelTable.Rows.Count;
                        for (int idx = 0; idx < rowcount; idx++)
                        {
                            //唯一列
                            _excelTable.Rows[idx][App.ColumnFixName_FID] = (idx + 1);

                            //接收人
                            string cnname = _excelTable.Rows[idx][App.ColumnName_Import_CnName].ToString();
                            string enname = _excelTable.Rows[idx][App.ColumnName_Import_EnName].ToString();
                            string number = _excelTable.Rows[idx][App.ColumnName_Import_JobNumber].ToString();
                            _excelTable.Rows[idx][App.ColumnFixName_FEmployeeAllName] = string.Format("{0}{1}{2}", cnname, enname, number);
                        }
                    }
                    #endregion
                }
                return _excelTable;
            }
        }
        private DataTable _excelTable = null;

        private void button1_Click_1(object sender, EventArgs e)
        {
            ucOneRowToReport1.SetData(table);
        }


    }
}
